let _ENV = 0;

function loadJs(type, url, callback) {
    if (type === 0) {
        const script = document.createElement('script');
        script.type = "text/javascript";
        if (typeof (callback) != "undefined") {
            if (script.readyState) {
                script.onreadystatechange = function () {
                    if (script.readyState === "loaded" || script.readyState === "complete") {
                        script.onreadystatechange = null;
                        callback();
                    }
                }
            } else {
                script.onload = function () {
                    callback();
                }
            }
        }
        script.src = url;
        document.body.appendChild(script);
    } else {
        return false
    }
}

loadJs(_ENV, "https://cdn.bootcss.com/vConsole/3.3.0/vconsole.min.js", () => {
    // eslint-disable-next-line no-undef
    new VConsole();
});

module.exports = loadJs;
